import * as dayjs from 'dayjs'

export interface logisticsListType {
  address: string,
  address_name: string,
  logistics_create_time: string
  logistics_result: string
  id: number
  logistics_settlement_time: string
  logistics_status: string
  logistics_update_time: string
  mobile: string
  order_id: number
  order_no: string
}


export interface logisticsQueryType {
  mobile: string
  address_name: string
  address: string
}

export const logisticsOptions =  [
  {
    label: '3',
    value: '待揽收'
  },
  {
    label: '4',
    value: '揽收中'
  },
  {
    label: '5',
    value: '运输中'
  },
  {
    label: '6',
    value: '中转中'
  },
  {
    label: '7',
    value: '清关中'
  },
  {
    label: '8',
    value: '发货到达'
  },
  {
    label: '9',
    value: '派送中'
  },
  {
    label: '10',
    value: '派送失败'
  },
  {
    label: '11',
    value: '派送异常'
  },
  {
    label: '12',
    value: '派送到达'
  },
  {
    label: '0',
    value: '已下单'
  },
  {
    label: '1',
    value: '已发货'
  },
  {
    label: '2',
    value: '已出库'
  },
  {
    label: '13',
    value: '签收'
  },
]

export const logisticsColumns = (opar) => [
  {
    title: "订单编号",
    align: "center",
    key: 'order_no',
    render: (r:logisticsListType) => {
      return r.order_no.split("-").join("")
    }
  },
  {
    title: "物流状态",
    key: 'logistics_status',
    align: "center",
    render: (r:logisticsListType) => {
      // r.logistics_status
      const obj = logisticsOptions.filter(item => item.label === r.logistics_status)
      console.log(r.logistics_status)
      if (obj.length) {
        return obj[0].value
      }
      return ""
    }
  },
  {
    title: "收件人姓名",
    key: 'address_name',
    align: "center"
  },
  {
    title: "收件人手机号",
    key: 'mobile',
    align: "center"
  },
  {
    title: "收件人地址",
    key: 'address',
    align: "center"
  },
  {
    title: "物流更新时间",
    key: "logistics_update_time",
    align: "center",
    render: (r: logisticsListType) => {
      return dayjs(r.logistics_update_time).format("YYYY-MM-DD HH:mm:ss")
    }
  },
  {
    title: "操作",
    key: "id",
    align: 'center',
    render: opar
  }
]
